<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>${appname}-<c:if test="${!empty sessionScope._local_node_session}">${sessionScope._local_node_session.nodeName}-</c:if>${si:ctname("NET_TYPE",sessionScope._netType)}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<script type="text/javascript">
jQuery(function($) {

	 if('${param.islocal}' =='0'){
		 	$('#islocal_true').removeClass("active");
			$('#islocal_false').addClass("active");
	 	}else{
	 		$('#islocal_true').addClass("active");
	 		$('#islocal_false').removeClass("active");
	 	}
})
	function submit(){
		$("#searchForm").submit();
	}

	function deleteById(id){
		ui.confirm('确认删除?',function(){
			$.ajax({
				   type: "POST",
				   dataType:"json",
				   cache: false,
				   url: _ctx + "/registry/node_pipeline_delete.do",
				   data: {id:id},
				   success: function(resp){
					   if(resp.status == '1'){
						   ui.msg(resp.msg, 1);
						   ui.go(_ctx + '/registry/node_pipeline_list.do');
					   }else{
						   ui.msg(resp.msg, 0);
					   }
				   },
				   error:function(){
					   ui.msg('信息加载错误', 0);
				   }
			});
		});	
	}
	/**
	批量删除
	**/
	function batchDelete(){
		var ids = $("input[name='ids']:checked");//jquery语法，选择页面中所有input表单中name=ids且被选中的值
		if(ids.length == 0){
			alert('请选择要删除的记录!');
			return;
		}	
		
		var validIds = new Array();
		var idAndStatus = null;
		var id = null;
		var status = null;
		for(var i=0;i<ids.length;i++){
			validIds.push($(ids[i]).val());
		}
		var idsVal = "";
		for(var i=0;i<validIds.length;i++){
			idsVal += validIds[i] +",";
		}
		idsVal = idsVal.substring(0,idsVal.length - 1);
		ui.confirm('确认删除?',function(){
			$.ajax({
				   type: "POST",
				   dataType:"json",
				   cache: false,
				   url: _ctx + "/registry/batch_node_pipeline_delete.do",
				   data: {"ids":idsVal},
				   success: function(resp){
					   if(resp.status == '1'){
						   ui.msg(resp.msg, 1);
						   ui.go(_ctx + '/registry/node_info_list.do');
					   }else{
						   ui.msg(resp.msg, 0);
					   }
				   },
				   error:function(){
					   ui.msg('信息加载错误', 0);
				   }
			});
		});	
	}
	function search(form) {
		$(form).appendPagerParaStr();
		return true;
	}


	 function nodePipelineList(val){
		 $('#islocal').val(val);
	 	if(val=='0'){
			$('#islocal_true').removeClass("active");
			$('#islocal_false').addClass("active");
	 	}else{
	 		$('#islocal_true').addClass("active");
	 		$('#islocal_false').removeClass("active");
	 	}
	 	$('#searchForm').submit();
	}
	 function nodePipelineGet(id){
			$.ajax({
				   type: "GET",
				   dataType:"html",
				   cache: false,
				   url: _ctx + "/registry/node_pipeline_get.do",
				   data: {id:id},
				   success: function( content ){
					   $('#data').html( content ); 
					   $('#myModal').modal('show');
				   },
				   error:function(){
					   ui.msg('信息加载错误', 0);
				   }
			});
		}
</script>
</head>
<body>
<%@ include file="/WEB-INF/view/common/topbar.jsp"%>
<div class="main-container" id="main-container">
	<div class="main-container-inner">
		<%@ include file="/WEB-INF/view/common/sidebar.jsp"%>
		<div class="main-content">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li>
							<i class="icon-home home-icon"></i>
							<a href="#">首页</a>
						</li>
						<li>
							<a href="#">传输通道管理</a>
						</li>
						<li class="active">列表</li>
					</ul>
					</div>
				  <div class="page-content">
				  	<div class="row">
				  		<div class="col-xs-12">
				  			<div class="widget-box">
				  				<div class="widget-header header-color-white">
									<div class="widget-toolbar no-border">
										<a class="btn btn-primary btn-xs" href="${ctx}/registry/node_pipeline_add.do"><i class="icon-plus-sign icon-on-right"></i> 新增&nbsp;&nbsp;</a>
										<a href="#" data-action="collapse">
											<i class="icon-chevron-up"></i>
										</a>
									</div>
								</div>
					  			<div class="widget-body">
									<div class="widget-main">
									  	<form  id="searchForm"  class="form-search"  action="${ctx}/registry/node_pipeline_list.do"  method="post" onsubmit="return search(this)">
										  <div class="row">
											  <div class="col-xs-4">
													<div class="input-group">
													   <span class="input-group-addon">通道类型</span>
													    <select name="pipeType"  id="pipeType" class="form-control input-sm"    >
												    		<option value="">请选择</option>
												    	${si:ctoption("PIPE_TYPE", param.pipeType) }
												    	</select>
													  </div>
												</div>
											    <div class="col-xs-4">
													<div class="input-group">
														<input type="hidden" id="islocal" name="islocal" value="${param.islocal }">
													    <span class="input-group-addon">所属节点</span>
													    <input type="text" class=" form-control search-query"  id="searchNodeName" name="searchNodeName"  value="${param.searchNodeName}"/>
													    <span class="input-group-btn">
															<button type="submit" class="btn btn-purple btn-sm" onclick="return formSubmit();">
																<i class="icon-search icon-on-right bigger-110"></i>
																搜索
															</button>
														</span>
												   </div>
												</div>
											</div>
										</form>
										</div>
								</div>
						</div>
				  	<div class="hr hr12 hr-dotted"></div>
				  	 <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab">
						  <li id="islocal_true" ><a  href="javascript:void(0);"  class="navbar-link"  onclick="nodePipelineList('1');">本地节点</a></li>
						  <li id="islocal_false" ><a  href="javascript:void(0);"  class="navbar-link" onclick="nodePipelineList('0');">交换节点</a></li>
					</ul>
				  	<div class="table-responsive">
					<table class="table table-striped table-bordered table-hover">
					  <thead>
				        <tr>
							<th class="center" >序号</th>
							<th >通道类型</th>
							<th >所属节点</th>
							<th >修改时间</th>
							<th >操作</th>
				        </tr>
					    </thead>
						<tbody>
						<c:forEach var="vo" items="${_data}" varStatus="idx">
						  <tr>
						  	<td class="center">${idx.index + 1}</td>
							<td>${si:ctname("PIPE_TYPE",vo.pipeType)}</td>
							<td>${vo.nodeName}</td>
							<td>${si:fmtDate(vo.mtime)}</td>
							<td>
								<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
									<a class="blue" href="javascript:void(0);" onclick="nodePipelineGet('${vo.id }');" title="查看">
											<i class="icon-zoom-in bigger-130"></i>
										</a>
									<c:if test="${vo.isLocal eq 1 }">
										<a class="green" href="${ctx}/registry/node_pipeline_update/${vo.id }.do" title="修改">
											<i class="icon-pencil bigger-130"></i>
										</a>
										<a class="red" href="${ctx}/registry/node_pipeline_shutdown/${vo.id }.do" title="停用">
											<i class="icon-stop bigger-130"></i> 
										</a>
									</c:if>
								</div>
								<div id="myModal" class="modal fade" role="dialog"  tabindex="-1" aria-labelledby="查看" aria-hidden="false">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header">
									      </div>
											<div   id="data">
								  			</div>
											<div class="modal-footer wizard-actions">
												<button class="btn btn-danger btn-sm pull-left" data-dismiss="modal">
													<i class="icon-remove"></i>
													关闭
												</button>
											</div>
										</div>
									</div>
								</div>
							</td>
						  </tr>
						</c:forEach>
						</tbody>
					</table>
					<jsp:include page="/WEB-INF/view/common/pg.jsp">
						<jsp:param value="${ctx }/registry/node_pipeline_list.do" name="url"/>
						<jsp:param value="${_total}" name="total"/>
						<jsp:param value="${_urlpara}" name="urlpara" />
				    </jsp:include>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>
